
import React, {Fragment} from "react";
import {Alert, Tabs} from "antd";
import NoTableNoModel from "./NoTableNoModel";
import Store from "./Store";
import {observer} from "mobx-react";
import HasTableNoModel from "./HasTableNoModel";

@observer
class ModelConfig extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            modelType:1
        }
    }

    handleModelTypeChange = (type) => {
        Store.modelType = type;
    };

    render() {
        const { TabPane } = Tabs;
        return (
            <Fragment>
                {Store.modelInfo &&  <div>
                    <Alert closable showIcon type={"info"} message={"模型信息"}
                           style={{width: 750,marginBottom:"10px", color: '#31708f !important'}}
                           description={(<div>
                               数据表：{Store.modelInfo["tableName"]} <br/>
                               模型类：{Store.modelInfo["modelClass"]} <br/>
                               模型类名：{Store.modelInfo["modelClassName"]} <br/>
                               最后更新时间：{Store.modelInfo["update_at"]}
                           </div>)}
                    />
                    <Tabs activeKey={Store.modelType} tabPosition={"left"} onChange={this.handleModelTypeChange}>
                        <TabPane tab="自定义生成" key={"1"}>
                            <NoTableNoModel />
                        </TabPane>
                        <TabPane tab="数据表生成" key={"2"}>
                            <HasTableNoModel />
                        </TabPane>
                    </Tabs>
                </div>}
            </Fragment>
        );
    }
}

export default ModelConfig;

